USE [GESTION_MORA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_D0007_LIMPIA_HISTORICOS_SALDOS]    Script Date: 11/23/2011 15:19:09 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_D0007_LIMPIA_HISTORICOS_SALDOS]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_D0007_LIMPIA_HISTORICOS_SALDOS]
GO

USE [GESTION_MORA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_D0007_LIMPIA_HISTORICOS_SALDOS]    Script Date: 11/23/2011 15:19:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[WASP_D0007_LIMPIA_HISTORICOS_SALDOS]
AS

declare @fecha_aux datetime
select @fecha_aux = max(fecha) from gmhistoricosaldo
select  
 @fecha_aux = DATEADD(day, -3, @fecha_aux) 
--print @fecha_aux
delete from gmhistoricosaldo where fecha < @fecha_aux
GO

